import 'package:flutter/material.dart';
import 'package:flutter_bilibili/core/extension/int_extension.dart';
import 'package:flutter_bilibili/ui/shared/app_theme.dart';
import '../../widgets/rectangle_checkBox.dart';

//用户协议、隐私政策、寻求帮助
class buildLoginAgreement extends StatefulWidget {
  const buildLoginAgreement({Key? key}) : super(key: key);

  @override
  State<buildLoginAgreement> createState() => _buildLoginAgreementState();
}

class _buildLoginAgreementState extends State<buildLoginAgreement> {
  var flag = true;

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 15.px),
      child: Column(
        children: [
          GestureDetector(  //checkbox
            onTap: () {
              setState(() {
                flag = !flag;
              });
            },
            child: Text.rich(   //实现换行
              TextSpan(
                children: [
                  WidgetSpan(
                    child: RectangleCheckBox(  //自定义矩形的checkbox
                      size: 15.px,
                      checkedColor: HYAppTheme.norTextColors,
                      isChecked: flag,
                      onTap: (value) {
                        setState(() {
                          flag = value!;
                        });
                      },
                    ),
                  ),
                  TextSpan(
                    text: "   我已经阅读并同意",
                    style: TextStyle(
                        color: Colors.grey, fontSize: HYAppTheme.xxSmallFontSize),
                  ),
                  TextSpan(
                    text: "用户协议",
                    style: TextStyle(
                        color: Colors.blue, fontSize: HYAppTheme.xxSmallFontSize),
                  ),
                  TextSpan(
                    text: "和",
                    style: TextStyle(
                        color: Colors.grey, fontSize: HYAppTheme.xxSmallFontSize),
                  ),
                  TextSpan(
                    text: "隐私政策",
                    style: TextStyle(
                        color: Colors.blue, fontSize: HYAppTheme.xxSmallFontSize),
                  ),
                  TextSpan(
                    text: "，未注册绑定的手机号验证成功后将自动注册",
                    style: TextStyle(
                        color: Colors.grey, fontSize: HYAppTheme.xxSmallFontSize),
                  ),
                ],
              ),
            ),
          ),
          SizedBox(
            height: 20.px,
          ),
          Text.rich(
            TextSpan(
              children: [
                TextSpan(
                  text: "遇到问题？",
                  style: TextStyle(
                      color: Colors.grey, fontSize: HYAppTheme.xxSmallFontSize),
                ),
                TextSpan(
                  text: "查看帮助",
                  style: TextStyle(
                      color: Colors.blue, fontSize: HYAppTheme.xxSmallFontSize),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
